package com.cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/cookieServlet3")
public class CookieServlet3 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("执行了CookieServlet3...");

        //创建cookie对象
        Cookie c1 = new Cookie("name", "tom");
        Cookie c2 = new Cookie("name", "jerry");

        //添加cookie信息, 设置cookie的响应信息
        response.addCookie(c1);
        response.addCookie(c2);

        System.out.println("添加完成...");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
